<%@ page import="com.itheima.domain.Address" %>
<%@ page import="com.itheima.domain.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>EL表达式</title>
</head>
<body>
      <%
         String name ="admin1";

          Address add =new Address();
          add.setCity("hefei");

          User user =new User();
          user.setId(1);
          user.setPwd("123");
          user.setUsername("aaaa1");
          User user1 =new User();
          user1.setId(2);
          user.setPwd("123");
          user.setUsername("aaaa2");
          User user2 =new User();
          user2.setId(3);
          user2.setPwd("123");
          user2.setUsername("aaaa3");

          User user3 =new User();
          user.setId(4);
          user3.setPwd("123");
          user3.setUsername("aaaa4");
          //pageContext.setAttribute("username","pageData");
          //request.setAttribute("username","requestData");
          //sesssion.setAttribute("username","sessionData");
          //application.setAttribute("username","appData");
          pageContext.setAttribute("u",user);
          request.setAttribute("u",user1);
          session.setAttribute("u",user2);
          application.setAttribute("u",user3);
      %>
      <%=name%><br>
      <%--从作用域中获取String类型数据--%>
el:${username}<br>
username1:${u.getUsername()}<br/>
<%--el表达式底层调用getUsername()--%>
username2:${u.username}<br/>
pwd:${u.pwd}<br>
<%--明确从指定的作用域中获取数据--%>
requestUser:${requestScope.u.username}<br/>
sessionUser:${sessionScope.u.username}<br/>
appUser:${applicationScope.u.username}<br/>
address:${applicationScope.u.address.city}

<hr>
${1+1}<br>
${1>1&&1==1}<br>
${1==1?"yes":"no"}
<hr>

<%
   List<User> list =new ArrayList<>();
   User u =new User();
   u.setId(1);
   u.setPwd("123");
   u.setUsername("aaaa1");
   User u1 =new User();
   u1.setId(2);
   u1.setPwd("123");
   u1.setUsername("aaaa2");
   User u2 =new User();
   u2.setId(3);
   u2.setPwd("123");
   u2.setUsername("aaaa3");

   User u3 =new User();
   u3.setId(4);
   u3.setPwd("123");
   u3.setUsername("aaaa4");

   list.add(u);
   list.add(u1);
   list.add(u2);
   list.add(u3);
   request.setAttribute("list",list);
%>

${list[10].username}

</body>
</html>
